package com.feifei.service.impl;

import com.feifei.bean.User;
import com.feifei.bean.UserExample;
import com.feifei.mapper.UserMapper;
import com.feifei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public int addUser(User user) {
        return userMapper.insertSelective(user);
    }

    @Override
    public boolean checkUsername(String username) {
        User user = new User();
        user.setUsername(username);
        User user1 = userMapper.selectByUsername(user);
        System.out.println(user1);
        if (user1 == null) {
            return false;
        } else {
            return true;
        }
    }
//登录操作
    @Override
    public User userLogin(User user) {
        User user1 = userMapper.loginByUSer(user);
        return user1;
    }

    @Override
    public User getUserById(Integer id) {
        User user = userMapper.selectByPrimaryKey(id);
        return user;
    }
}
